Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow multiple root spans to exist in a tracetest trace #2518

Merged
merged 1 commit into from
May 10, 2023

Conversation

mathnogueira
Copy link
Contributor

This PR allows our traces to have multiple root spans. They will always be children of the trigger span

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@mathnogueira
Copy link
Contributor Author

This is related to the issue #2517

@mathnogueira mathnogueira changed the title feat: allow multiple roots to exist in a tracetest test feat: allow multiple root spans to exist in a tracetest test May 10, 2023
@mathnogueira mathnogueira changed the title feat: allow multiple root spans to exist in a tracetest test feat: allow multiple root spans to exist in a tracetest trace May 10, 2023
@@ -23,23 +23,30 @@ func NewTrace(traceID string, spans []Span) Trace {
spanMap[spanID] = &spanCopy
}

var rootSpan *Span = nil
rootSpans := make([]*Span, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to preallocate the space?

Suggested change
rootSpans := make([]*Span, 0)
rootSpans := make([]*Span, 0, len(spanMap))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth it because most traces have only one root span. This would allocate way too much space in most cases.

Copy link
Contributor

@schoren schoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@schoren schoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mathnogueira mathnogueira merged commit a8c132f into main May 10, 2023
@mathnogueira mathnogueira deleted the fix/multiple-trace-roots branch May 10, 2023 18:35
@mathnogueira mathnogueira restored the fix/multiple-trace-roots branch May 10, 2023 18:43
@xoscar xoscar deleted the fix/multiple-trace-roots branch May 26, 2023 17:41
schoren pushed a commit that referenced this pull request Jun 5, 2023
allow multiple roots to exist in a tracetest test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants